package com.cy.pj.module.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.ArrayList;
import java.util.List;

@Controller
public class ModelViewController {
    @RequestMapping("/doModelAndView")
    public String doModelAndView(Model model){
        model.addAttribute("name", "jason");
        model.addAttribute("age", "20");
    return "view";
    }

    @RequestMapping("/doModelAndView01")
    public ModelAndView doModelAndView01(ModelAndView mv){
        mv.addObject("name","j");
        mv.addObject("state",true);
        mv.setViewName("view");
        return mv;
    }

    @RequestMapping("/doModelAndView02")
    public ModelAndView doModelAndView02(ModelAndView mv){
        List<String> list =  new ArrayList<>();
        list.add("背景");
        list.add("动画");
        list.add("娱乐");
        mv.addObject("citys", list);
        mv.setViewName("view");
        return mv;
    }

}
